<%@page import="key.Info"%>
<%@page import="key.Log"%>
<%@page import="key.Database"%>
<%@page import="key.Frame"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	Database db = new Database();
	String week = db.getWeek();
%>
<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">

<title>琴房预订系统</title>
<link rel="stylesheet" href="css/pci.css">
</head>
<body>
	<%
		String uname = (String) request.getAttribute("uname");
		String uid = (String) request.getAttribute("uid");
		Object obj = request.getAttribute("timeList");
		String inf = (String) request.getAttribute("inf");

		session.setAttribute("uid", uid);
		session.setAttribute("uname", uname);
		session.setAttribute("timeList", obj);

		Log log = new Log();
		List<Info> timeList = null;
		if (!(obj instanceof List) || obj == null) {
			log.writeIn("inf.jsp: 数据传输出错或非法请求");

			/* 生成页面 */
	%>
	<script type='text/javascript'>
		confirm("数据传输出错或非法请求\nuname: "+<%=uname%>+"\nuid: "+<%=uid%>);
		window.location.href = "index.jsp";
	</script>
	<%
		/*response.sendRedirect("index.jsp");
			Frame fr = new Frame(uname, uid, "页面出错或非法请求");*/
		} else {
			timeList = (List<Info>) obj;
	%>
	<%
		if (inf != null && !inf.equals("")) {
	%>
	<script type="text/javascript">
		alert("<%=inf%>");
	</script>
	<%
		inf = null;
			}
	%>
	<nav class="navbar navbar-inverse navbar-fixed-top">
		<div class="container-fluid">
			<div class="navbar-header">
				<a class="navbar-brand">Welcome <%=uname%></a>
			</div>
			<div id="navbar" class="navbar-collapse collapse">
				<ul class="nav navbar-nav navbar-right">
					<li><a>Home</a></li>
					<li><a href="InfAdd">Add</a></li>
					<li><a href="InfDelete">Delete</a></li>
				</ul>
			</div>
		</div>
	</nav>

	<div class="container-fluid">
		<div class="row">
			<h1>
				The
				<%=week%>
				Week
			</h1>
			<div class="table-responsive">
				<table class="table table-striped">
					<thead>
						<tr>
							<th>Time</th>
							<th>MON.</th>
							<th>TUE.</th>
							<th>WED.</th>
							<th>THU.</th>
							<th>FRI.</th>
							<th>SAT.</th>
							<th>SUN.</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td class="time">8 - 9</td>
							<%
								for (int id = 108; id < 800; id += 100) {//生成动态信息表格
										for (Info info : timeList) {
											int flag = Integer.parseInt(info.getTid());
											if (flag == id) {//找到
												String display = info.getUname();
												if (display.equals(uname)) {
							%>
							<td class="selected"><%=display%></td>
							<%
								} else if (display.equals("Disable")) {
							%>
							<td class="disable">Disable</td>
							<%
								} else if (display.equals("Empty")) {
							%>
							<td>Empty</td>
							<%
								} else {
							%>
							<td class="others"><%=display%></td>
							<%
								}
											}
										}
									}
							%>
						</tr>
						<tr>
							<td class="time">9 - 10</td>
							<%
								for (int id = 109; id < 800; id += 100) {//生成动态信息表格
										for (Info info : timeList) {
											int flag = Integer.parseInt(info.getTid());
											if (flag == id) {//找到
												String display = info.getUname();
												if (display.equals(uname)) {
							%>
							<td class="selected"><%=display%></td>
							<%
								} else if (display.equals("Disable")) {
							%>
							<td class="disable">Disable</td>
							<%
								} else if (display.equals("Empty")) {
							%>
							<td>Empty</td>
							<%
								} else {
							%>
							<td class="others"><%=display%></td>
							<%
								}
											}
										}
									}
							%>
						</tr>
						<tr>
							<td class="time">10 - 11</td>
							<%
								for (int id = 110; id < 800; id += 100) {//生成动态信息表格
										for (Info info : timeList) {
											int flag = Integer.parseInt(info.getTid());
											if (flag == id) {//找到
												String display = info.getUname();
												if (display.equals(uname)) {
							%>
							<td class="selected"><%=display%></td>
							<%
								} else if (display.equals("Disable")) {
							%>
							<td class="disable">Disable</td>
							<%
								} else if (display.equals("Empty")) {
							%>
							<td>Empty</td>
							<%
								} else {
							%>
							<td class="others"><%=display%></td>
							<%
								}
											}
										}
									}
							%>
						</tr>
						<tr>
							<td class="time">11 - 12</td>
							<%
								for (int id = 111; id < 800; id += 100) {//生成动态信息表格
										for (Info info : timeList) {
											int flag = Integer.parseInt(info.getTid());
											if (flag == id) {//找到
												String display = info.getUname();
												if (display.equals(uname)) {
							%>
							<td class="selected"><%=display%></td>
							<%
								} else if (display.equals("Disable")) {
							%>
							<td class="disable">Disable</td>
							<%
								} else if (display.equals("Empty")) {
							%>
							<td>Empty</td>
							<%
								} else {
							%>
							<td class="others"><%=display%></td>
							<%
								}
											}
										}
									}
							%>
						</tr>
						<tr>
							<td class="time">12 - 13</td>
							<%
								for (int id = 112; id < 800; id += 100) {//生成动态信息表格
										for (Info info : timeList) {
											int flag = Integer.parseInt(info.getTid());
											if (flag == id) {//找到
												String display = info.getUname();
												if (display.equals(uname)) {
							%>
							<td class="selected"><%=display%></td>
							<%
								} else if (display.equals("Disable")) {
							%>
							<td class="disable">Disable</td>
							<%
								} else if (display.equals("Empty")) {
							%>
							<td>Empty</td>
							<%
								} else {
							%>
							<td class="others"><%=display%></td>
							<%
								}
											}
										}
									}
							%>
						</tr>
						<tr>
							<td class="time">13 - 14</td>
							<%
								for (int id = 113; id < 800; id += 100) {//生成动态信息表格
										for (Info info : timeList) {
											int flag = Integer.parseInt(info.getTid());
											if (flag == id) {//找到
												String display = info.getUname();
												if (display.equals(uname)) {
							%>
							<td class="selected"><%=display%></td>
							<%
								} else if (display.equals("Disable")) {
							%>
							<td class="disable">Disable</td>
							<%
								} else if (display.equals("Empty")) {
							%>
							<td>Empty</td>
							<%
								} else {
							%>
							<td class="others"><%=display%></td>
							<%
								}
											}
										}
									}
							%>
						</tr>
						<tr>
							<td class="time">14 - 15</td>
							<%
								for (int id = 114; id < 800; id += 100) {//生成动态信息表格
										for (Info info : timeList) {
											int flag = Integer.parseInt(info.getTid());
											if (flag == id) {//找到
												String display = info.getUname();
												if (display.equals(uname)) {
							%>
							<td class="selected"><%=display%></td>
							<%
								} else if (display.equals("Disable")) {
							%>
							<td class="disable">Disable</td>
							<%
								} else if (display.equals("Empty")) {
							%>
							<td>Empty</td>
							<%
								} else {
							%>
							<td class="others"><%=display%></td>
							<%
								}
											}
										}
									}
							%>
						</tr>
						<tr>
							<td class="time">15 - 16</td>
							<%
								for (int id = 115; id < 800; id += 100) {//生成动态信息表格
										for (Info info : timeList) {
											int flag = Integer.parseInt(info.getTid());
											if (flag == id) {//找到
												String display = info.getUname();
												if (display.equals(uname)) {
							%>
							<td class="selected"><%=display%></td>
							<%
								} else if (display.equals("Disable")) {
							%>
							<td class="disable">Disable</td>
							<%
								} else if (display.equals("Empty")) {
							%>
							<td>Empty</td>
							<%
								} else {
							%>
							<td class="others"><%=display%></td>
							<%
								}
											}
										}
									}
							%>
						</tr>
						<tr>
							<td class="time">16 - 17</td>
							<%
								for (int id = 116; id < 800; id += 100) {//生成动态信息表格
										for (Info info : timeList) {
											int flag = Integer.parseInt(info.getTid());
											if (flag == id) {//找到
												String display = info.getUname();
												if (display.equals(uname)) {
							%>
							<td class="selected"><%=display%></td>
							<%
								} else if (display.equals("Disable")) {
							%>
							<td class="disable">Disable</td>
							<%
								} else if (display.equals("Empty")) {
							%>
							<td>Empty</td>
							<%
								} else {
							%>
							<td class="others"><%=display%></td>
							<%
								}
											}
										}
									}
							%>
						</tr>
						<tr>
							<td class="time">17 - 18</td>
							<%
								for (int id = 117; id < 800; id += 100) {//生成动态信息表格
										for (Info info : timeList) {
											int flag = Integer.parseInt(info.getTid());
											if (flag == id) {//找到
												String display = info.getUname();
												if (display.equals(uname)) {
							%>
							<td class="selected"><%=display%></td>
							<%
								} else if (display.equals("Disable")) {
							%>
							<td class="disable">Disable</td>
							<%
								} else if (display.equals("Empty")) {
							%>
							<td>Empty</td>
							<%
								} else {
							%>
							<td class="others"><%=display%></td>
							<%
								}
											}
										}
									}
							%>
						</tr>
						<tr>
							<td class="time">18 - 19</td>
							<%
								for (int id = 118; id < 800; id += 100) {//生成动态信息表格
										for (Info info : timeList) {
											int flag = Integer.parseInt(info.getTid());
											if (flag == id) {//找到
												String display = info.getUname();
												if (display.equals(uname)) {
							%>
							<td class="selected"><%=display%></td>
							<%
								} else if (display.equals("Disable")) {
							%>
							<td class="disable">Disable</td>
							<%
								} else if (display.equals("Empty")) {
							%>
							<td>Empty</td>
							<%
								} else {
							%>
							<td class="others"><%=display%></td>
							<%
								}
											}
										}
									}
							%>
						</tr>
						<tr>
							<td class="time">19 - 20</td>
							<%
								for (int id = 119; id < 800; id += 100) {//生成动态信息表格
										for (Info info : timeList) {
											int flag = Integer.parseInt(info.getTid());
											if (flag == id) {//找到
												String display = info.getUname();
												if (display.equals(uname)) {
							%>
							<td class="selected"><%=display%></td>
							<%
								} else if (display.equals("Disable")) {
							%>
							<td class="disable">Disable</td>
							<%
								} else if (display.equals("Empty")) {
							%>
							<td>Empty</td>
							<%
								} else {
							%>
							<td class="others"><%=display%></td>
							<%
								}
											}
										}
									}
							%>
						</tr>
						<tr>
							<td class="time">20 - 21</td>
							<%
								for (int id = 120; id < 800; id += 100) {//生成动态信息表格
										for (Info info : timeList) {
											int flag = Integer.parseInt(info.getTid());
											if (flag == id) {//找到
												String display = info.getUname();
												if (display.equals(uname)) {
							%>
							<td class="selected"><%=display%></td>
							<%
								} else if (display.equals("Disable")) {
							%>
							<td class="disable">Disable</td>
							<%
								} else if (display.equals("Empty")) {
							%>
							<td>Empty</td>
							<%
								} else {
							%>
							<td class="others"><%=display%></td>
							<%
								}
											}
										}
									}
							%>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
	</div>
</body>
</html>
<%
	}
%>
